package day15;

import java.util.Arrays;
import java.util.Comparator;

public class Algorithm06 {
    public static void main(String[] args) {
        Girlfriend gf1 = new Girlfriend("xiaoshishi",18,168);
        Girlfriend gf2 = new Girlfriend("xiaohuihui",20,171);
        Girlfriend gf3 = new Girlfriend("xiaodandan",19,170);
        Girlfriend[] arr = {gf1,gf2,gf3};
        Arrays.sort(arr,new Comparator<Girlfriend>() {
            @Override
            public int compare(Girlfriend o1, Girlfriend o2) {
                if(o1.getAge()==o2.getAge()){
                    if(o1.getHeight()==o2.getHeight()){
                        int i=o1.getName().compareTo(o2.getName())>0?1:-1;
                        return i;
                    }
                    return o1.getHeight()-o2.getHeight();
                }
                return o1.getAge()-o2.getAge();
            }
        });
        for (Girlfriend gf : arr) {
            System.out.println(gf);
        }
    }
}
